﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminFunction.Master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="BitPortal.Admin.Customer.Default" ViewStateMode="Enabled" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .bold-text
        {
            font-weight: bold;
            padding-left: 25px;
            font-size: 110%;
        }
    </style>
    <style type="text/css">
        .x-form-group .x-form-group-header-text
        {
            background-color: #dfe8f6;
        }
        
        .x-label-text
        {
            font-weight: bold;
            font-size: 11px;
        }
    </style>
    <style type="text/css">
        .x-grid3-cell-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid-group-hd div
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid3-hd-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
            font-size: 12px;
        }
        
        .x-grid3-body .x-grid3-td-Cost
        {
            background-color: #f1f2f4;
        }
        
        .x-grid3-summary-row .x-grid3-td-Cost
        {
            background-color: #e1e2e4;
        }
    </style>
    <script type="text/javascript">
        var template = '<img src="/Images/flag_16.png" style="display:{0};" />';

        var change = function (value) {
            return String.format(template, (value) ? "block" : "none");
        };
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="TopBarHolder" runat="server">
    <ext:ButtonGroup ID="ButtonGroup1" runat="server" Layout="ToolbarLayout">
        <Items>
            <ext:Button runat="server" ID="btnAdd" Text="Thêm khách hàng" Icon="ControlAddBlue"
                Scale="Medium" CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnAdd_Click"></Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnEdit" Text="Sửa khách hàng" Icon="Pencil" Scale="Medium"
                CausesValidation="false">
                <DirectEvents>
                    <Click OnEvent="btnEdit_Click">
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:SplitButton runat="server" ID="SplitButton1" Text="Cập nhật" Icon="Pencil" Scale="Medium">
                <Menu>
                    <ext:Menu ID="Menu1" runat="server">
                        <Items>
                            <ext:MenuItem ID="MenuItem1" runat="server" Text="Đánh dấu" Icon="FlagYellow">
                                <DirectEvents>
                                    <Click OnEvent="btnFlag_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="btnMarkAsUnreplied" runat="server" Text="Bỏ đánh dấu" Icon="FlagWhite">
                                <DirectEvents>
                                    <Click OnEvent="btnUnFlag_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem2" runat="server" Text="Duyệt thông tin" Icon="Accept">
                                <DirectEvents>
                                    <Click OnEvent="btnApprove_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem3" runat="server" Text="Không duyệt" Icon="Cross">
                                <DirectEvents>
                                    <Click OnEvent="btnUnApprove_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                        </Items>
                    </ext:Menu>
                </Menu>
            </ext:SplitButton>
            <ext:ToolbarSeparator />
            <ext:Button runat="server" ID="btnDelete" Text="Xóa khách hàng" Icon="Delete" Scale="Medium">
                <DirectEvents>
                    <Click OnEvent="btnDelete_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:ToolbarSeparator />
            <ext:SplitButton runat="server" ID="btnTrash" Text="Thùng rác" Icon="Bin" Scale="Medium">
                <Menu>
                    <ext:Menu ID="Menu2" runat="server">
                        <Items>
                            <ext:MenuItem ID="MenuItem8" runat="server" Text="Xóa tất cả" Icon="Cancel">
                                <DirectEvents>
                                    <Click OnEvent="btnTrashEmpty_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem9" runat="server" Text="Xóa những KH được chọn" Icon="BinEmpty">
                                <DirectEvents>
                                    <Click OnEvent="btnTrashDelete_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                            <ext:MenuItem ID="MenuItem10" runat="server" Text="Bỏ khỏi thùng rác" Icon="ArrowTurnLeft">
                                <DirectEvents>
                                    <Click OnEvent="btnUnDelete_Click">
                                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                                    </Click>
                                </DirectEvents>
                            </ext:MenuItem>
                        </Items>
                    </ext:Menu>
                </Menu>
                <DirectEvents>
                    <Click OnEvent="btnTrash_Click">
                        <EventMask ShowMask="true" Msg="Waiting..." MinDelay="500" />
                    </Click>
                </DirectEvents>
            </ext:SplitButton>
        </Items>
    </ext:ButtonGroup>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <uc:CustomerAddEdit runat="server" ID="CustomerAddEdit1" />
    <ext:Store ID="Store1" runat="server" OnRefreshData="Store1_RefreshData" RemoteSort="true"
        RemotePaging="true">
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="CustomerID">
                <Fields>
                    <ext:RecordField Name="CustomerID" Type="Auto" />
                    <ext:RecordField Name="ContactName" Type="String" />
                    <ext:RecordField Name="Company" Type="String" />
                    <ext:RecordField Name="Email" Type="String" />
                    <ext:RecordField Name="Phone" Type="String" />
                    <ext:RecordField Name="Fax" Type="String" />
                    <ext:RecordField Name="Address" Type="String" />
                    <ext:RecordField Name="GroupName" Type="String" />
                    <ext:RecordField Name="Description" Type="String" />
                    <ext:RecordField Name="City" Type="String" />
                    <ext:RecordField Name="Country" Type="String" />
                    <ext:RecordField Name="LastContactForm" Type="String" />
                    <ext:RecordField Name="LastRepliedForm" Type="String" />
                    <ext:RecordField Name="LastContactDate" Type="Date" DateFormat="yyyy-MM-ddTHH:mm:ss" />
                    <ext:RecordField Name="LastRepliedDate" Type="Date" DateFormat="yyyy-MM-ddTHH:mm:ss" />
                    <ext:RecordField Name="IsApproved" Type="Boolean" />
                    <ext:RecordField Name="IsFlag" Type="Boolean" />
                    <ext:RecordField Name="Priority" Type="Int" />
                    <ext:RecordField Name="Logs_DatetimeCreated" Type="Date" ServerMapping="Logs.DatetimeCreated" />
                    <ext:RecordField Name="NoteGroupID" Type="Auto" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="limit" Value="10" Mode="Raw" />
            <ext:Parameter Name="sort" Value="" />
            <ext:Parameter Name="dir" Value="" />
        </BaseParams>
        <SortInfo Field="CustomerID" Direction="DESC" />
    </ext:Store>
    <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" Title="Danh sách khách hàng"
        StoreID="Store1" Frame="true" AutoWidth="true">
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column Header="" DataIndex="IsFlag" Align="Center" Width="25" Resizable="false">
                    <Renderer Fn="change" />
                </ext:Column>
                <ext:ImageCommandColumn Header="" Align="Center" Width="25" Resizable="false">
                    <Commands>
                        <ext:ImageCommand CommandName="MyCommand" Icon="Note" ToolTip-Text="Xem ghi chú">
                        </ext:ImageCommand>
                    </Commands>
                </ext:ImageCommandColumn>
                <ext:Column Header="Mã" DataIndex="CustomerID" Groupable="false" Width="30" />
                <ext:Column Header="Người liên hệ" DataIndex="ContactName" Width="150" />
                <ext:Column Header="Công ty" DataIndex="Company" Width="150" />
                <ext:GroupingSummaryColumn Header="Nhóm" DataIndex="GroupName" Groupable="true" SummaryType="Count">
                    <SummaryRenderer Handler="return ((value === 0 || value > 1) ? '(' + value +' khách hàng)' : '(1 khách hàng)');" />
                </ext:GroupingSummaryColumn>
                <ext:Column Header="Email" DataIndex="Email" Width="150" />
                <ext:Column Header="Phone" DataIndex="Phone" Width="100" />
                <ext:Column Header="Fax" DataIndex="Fax" Hidden="true" Width="100" />
                <ext:Column Header="Quốc qia" DataIndex="Country" Hidden="true" Width="100" />
                <ext:Column Header="Thành phố" DataIndex="City" Hidden="true" Width="100" />
                <ext:Column Header="Địa chỉ" DataIndex="Address" Hidden="true" Width="150" />
                <ext:Column Header="Liên hệ cuối" DataIndex="LastContactForm" Hidden="true" Width="150" />
                <ext:Column Header="Trả lời cuối" DataIndex="LastRepliedForm" Hidden="true" Width="150" />
                <ext:NumberColumn Header="Ưu tiên" DataIndex="Priority" Hidden="true" Width="100" />
                <ext:DateColumn Header="Ngày liên hệ cuối" DataIndex="LastContactDate" Align="Center"
                    Format="dd-MM-yyyy" Hidden="true" Width="100" />
                <ext:DateColumn Header="Ngày trả lời cuối" DataIndex="LastRepliedDate" Align="Center"
                    Format="dd-MM-yyyy" Hidden="true" Width="100" />
                <ext:DateColumn Header="Ngày tạo" DataIndex="Logs_DatetimeCreated" Align="Center"
                    Format="dd-MM-yyyy" Width="100" />
                <ext:Column Header="Kiểm duyệt" DataIndex="IsApproved" Align="Center" Width="100">
                    <Renderer Handler="return (value) ? 'Có':'Không';" />
                </ext:Column>
            </Columns>
        </ColumnModel>
        <Listeners>
            <Command Handler="Ext.net.DirectMethods.LoadNotes(record.data.NoteGroupID);" />
        </Listeners>
        <SelectionModel>
            <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" />
        </SelectionModel>
        <View>
            <ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" MarkDirty="false"
                ShowGroupName="true" EnableNoGroups="true" HideGroupedColumn="true" ShowGroupsText="Nhóm lại theo cột này" />
        </View>
        <LoadMask ShowMask="true" />
        <Plugins>
            <ext:GridFilters runat="server" ID="GridFilters1">
                <Filters>
                    <ext:NumericFilter DataIndex="CustomerID" />
                    <ext:StringFilter DataIndex="ContactName" />
                    <ext:StringFilter DataIndex="Company" />
                    <ext:StringFilter DataIndex="Email" />
                    <ext:StringFilter DataIndex="Phone" />
                    <ext:StringFilter DataIndex="Fax" />
                    <ext:StringFilter DataIndex="Country" />
                    <ext:StringFilter DataIndex="City" />
                    <ext:StringFilter DataIndex="Address" />
                    <ext:StringFilter DataIndex="LastRepliedForm" />
                    <ext:StringFilter DataIndex="LastContactForm" />
                    <ext:NumericFilter DataIndex="Priority" />
                    <ext:DateFilter DataIndex="LastContactDate">
                        <DatePickerOptions runat="server" TodayText="Now" />
                    </ext:DateFilter>
                    <ext:DateFilter DataIndex="LastRepliedDate">
                        <DatePickerOptions runat="server" TodayText="Now" />
                    </ext:DateFilter>
                    <ext:DateFilter DataIndex="Logs_DatetimeCreated">
                        <DatePickerOptions runat="server" TodayText="Now" />
                    </ext:DateFilter>
                    <ext:BooleanFilter DataIndex="IsApproved" />
                    <ext:BooleanFilter DataIndex="IsFlag" />
                </Filters>
            </ext:GridFilters>
            <ext:RowExpander ID="RowExpander1" runat="server">
                <Template ID="Template1" runat="server">
                    <Html>
                        <div style="padding: 10px; line-height: 1.5em">
							<p><b>Địa chỉ:</b> {Address} - {City} - {Country}</p>
                            <p style="color:#999"><b>Thông tin: </b>{Description}</p>
							<p><b>Lần liên hệ cuối:</b> {LastContactDate} - {LastContactForm}</p>
							<p><b>Lần trả lời cuối:</b> {LastRepliedDate} - {LastRepliedForm}</p>
                        </div>
                    </Html>
                </Template>
            </ext:RowExpander>
        </Plugins>
        <BottomBar>
            <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="10" />
        </BottomBar>
    </ext:GridPanel>
    <ext:Window ID="wCustomerNote" runat="server" Collapsible="true" Icon="Note" Title="Notes"
        Width="960" Height="500" AutoScroll="true" Hidden="true" ButtonAlign="Center"
        AutoDataBind="false" Modal="true" Maximizable="true">
        <AutoLoad ShowMask="true" Mode="IFrame" />
    </ext:Window>
</asp:Content>
